#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    
    string t;
    cin>>t;
    int n=t.size();

    vector<int> left(2*n+1,0),right(2*n+1,0);
    vector<char> s(2*n+1,'#');
    vector<int> r(2*n+1,1);

    for(int i=0;i<n;i++){
        s[i*2+1]=t[i];
    }

    int rr=-1,rc=-1;
    for(int i=0;i<2*n+1;i++){
        int tr=i<rr?min(r[2*rc-i],rr-i):1;
        while(i+tr<s.size()&&i-tr>=0){
            if(s[i-tr]==s[i+tr])tr++;
            else break;
        }
        r[i]=tr;
        if(i+tr>rr){
            rr=i+tr;
            rc=i;
        }
        right[i-tr+1]=max(right[i-tr+1],tr-1);
        left[i+tr-1]=max(left[i+tr-1],tr-1);
    }

    for(int i=0;i<2*n;i+=2){
        left[i]=max(left[i],left[i+2]-2);
    }
    for(int i=2*n;i>0;i-=2){
        right[i]=max(right[i],right[i-2]-2);
    }

    int res=0;
    for(int i=0;i<s.size();i+=2){
        if(right[i]&&left[i])res=max(res,left[i]+right[i]);
    }
    cout<<res;
}
